const PREFIX = 'cache_'

class Store {
  constructor(device) {
    this.store = device
  }

  get(key) {
    return this.store.get(key)
  }

  set(key, value) {
    return this.store.set(`${PREFIX}${key}`, value)
  }

  remove(key) {
    return this.store.remove(key)
  }

  clear() {
    return this.store.clear()
  }
}

class SessionStore {
  constructor() {
    this.store = window.sessionStorage
  }

  get(key) {
    return this.store.getItem(key)
  }

  set(key, value) {
    return this.store.setItem(key, value)
  }

  remove(key) {
    return this.store.removeItem(key)
  }

  clear() {
    return this.store.clear()
  }
}

export const sessionStore = new Store(new SessionStore())
